<!--<!DOCTYPE html>-->
<!--<html>-->
<!--	<head>-->
<!--		<meta charset="utf-8">-->
<!--		<title></title>-->
<!--		<link rel="stylesheet" href="/static/layui/css/layui.css">-->
<!--		<script src="/static/layui/layui.js" charset="utf-8"></script>-->
<!--		&lt;!&ndash; 配置文件 &ndash;&gt;-->
<!--		<script type="text/javascript" src="/static/editor/ueditor.config.js"></script>-->
<!--		&lt;!&ndash; 编辑器源码文件 &ndash;&gt;-->
<!--		<script type="text/javascript" src="/static/editor/ueditor.all.js"></script>-->
<!--	</head>-->
<!--	<body>-->

		<form method="post" class="layui-form layui-form-pane" action="release.html" style="margin-left: 30px;">
			<fieldset class="layui-elem-field layui-field-title">
				<legend>发布</legend>

				<div class="layui-form-item">
					<label class="layui-form-label">标题</label>
					<div class="layui-input-block" style="width: 400px;">
						<input name="name" class="layui-input" type="text" placeholder="请输入标题"
							   autocomplete="off" lay-verify="required" value="{$item.name}">
					</div>
				</div>

				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">分类</label>
						<div class="layui-input-inline" style="z-index: 9999;">
							<select name="category_id" lay-search="" lay-verify="required" >
								<option value="">搜索或选择</option>
								{volist name="category" id="c"}
								<option
										{if $c.id == $item.category_id}selected{/if}

										value="{$c.id}">{$c.name}</option>
								{/volist}
<!--								<option value="">搜索或选择</option>-->

							</select>
						</div>
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">预估机况</label>
					<div class="layui-input-block">
						{volist name="condition" id="c"}
						<input name="conditions_id" title="{$c.name}" type="radio"
						{if $c.id == $item.conditions_id}checked="true"{/if}
						 value="{$c.id}}">/
						{/volist}

<!--						<input name="conditions_id" title="几乎全新" type="radio" checked="" value="0">/-->
<!--						<input name="conditions_id" title="二手" type="radio" value="1">-->

					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label" style="float: none;">描述</label>
					<div class="layui-inline" style="z-index: 9;margin-top: 20px ;width: 800px;">
<!--						&lt;!&ndash; 加载编辑器的容器 &ndash;&gt;-->
<!--						<script id="container" name="content" type="text/plain">-->
<!--						</script>-->
<!--						&lt;!&ndash; 实例化编辑器 &ndash;&gt;-->

						<textarea id="container"  name="info" style="display: none;">{$item.info}</textarea>
					</div>
				</div>


				<div class="layui-upload">
					<button class="layui-btn" id="test2" type="button">图片上传(可多张)</button>
					<blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;max-width: 770px;">
						预览图：
						<div class="layui-upload-list" id="demo2">



						</div>
					</blockquote>
				</div>



				<div class="layui-form-item">
					<label class="layui-form-label">价格</label>
					<div class="layui-input-block">
						<input name="price" class="layui-input" type="text" placeholder="￥"
							   autocomplete="off" lay-verify="price" style="width: 225px;" value="{$item.price}">
					</div>
				</div>

<!--				<div class="layui-form-item">-->
<!--					<label class="layui-form-label">联系人</label>-->
<!--					<div class="layui-input-block">-->
<!--						<input name="user" class="layui-input" type="text" placeholder="请输入联系人" autocomplete="off" lay-verify="required" style="width: 225px;">-->
<!--					</div>-->
<!--				</div>-->
<!--				-->

<!--				<div class="layui-form-item">-->
<!--					<div class="layui-inline">-->
<!--						<label class="layui-form-label">联系电话</label>-->
<!--						<div class="layui-input-inline" style="width: 400px;">-->
<!--							<input name="phone" class="layui-input" type="tel" autocomplete="off" lay-verify="required|phone" placeholder="请输入手机号码">-->
<!--						</div>-->
<!--					</div>-->
<!--				</div>-->

<!--				<input type="text" name="pics" id="pics"   >-->
				<div id="pics">

				</div>


				<div class="layui-form-item">
					<button class="layui-btn" lay-filter="demo2" lay-submit="">提交</button>
				</div>


			</fieldset>
		</form>
<!--	</body>-->
<script src="/static/js/jquery-3.4.1.min.js"></script>
	<script>
		picnum=1;
		//select的渲染
		layui.use('form', function() {
			var form = layui.form;
			form.verify({
				price: function(value) {
					if (!/^[0-9]+.?[0-9]*$/.test(value))
						return '格式有误，请填入非负整数';
				}
			})
		})

		//upload的启用
		layui.use('upload', function() {
			var $ = layui.jquery,
					upload = layui.upload;

			//多图片上传
			var uploadInst =upload.render({
				elem: '#test2',
				url: '/index/trade/upload', //改成您自己的上传接口
				field:'image',
				multiple: true,
				before: function (obj) {
					//预读本地文件示例，不支持ie8
					obj.preview(function (index, file, result) {
						$('#demo2').append('<img src="' + result + '" alt="' + file.name + '" class="layui-upload-img" style="height: 50px;width: 50px;padding-right: 50px">')
					});
				},
				done: function (res) {
					//如果上传失败
					if (res.code > 0) {
						return layer.msg('上传失败');
					}
					//上传成功
					console.log(res['data']['images']);
					let pic=res['data']['images'];

					$('#pics').append('<input type="text" name="pic'+picnum+'" value="'+pic+'" hidden>');
					picnum++;
					// pics=$('#pics');
					// pics.val(pics.val()+pic+';');
					console.log("成功啦！" + res  + upload);
				}
				, error: function () {
					//演示失败状态，并实现重传
					console.log("faild"  + upload);

				},
			});
		})

		function appendPic(result) {
			$('#demo2').append('<img src="' + result + '" alt="' + picnum + '" class="layui-upload-img" style="height: 50px;width: 50px;padding-right: 50px">')
			$('#pics').append('<input type="text" name="pic'+picnum+'" value="'+result+'" hidden>');
		}

		{if $item.pic1} appendPic("__UPLOAD__/{$item.pic1}"){/if}
		{if $item.pic2} appendPic("__UPLOAD__/{$item.pic2}"){/if}
		{if $item.pic3} appendPic("__UPLOAD__/{$item.pic3}"){/if}

	</script>


	<script>
		layui.use('layedit', function(){
			var layedit = layui.layedit;
			layedit.build('container'); //建立编辑器
		});
	</script>

<!--	<script type="text/javascript">-->
<!--		var ue = UE.getEditor('container');-->
<!--	</script>-->
<!--</html>-->
